"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var api_1 = require("../../../../config/api");
// import set = Reflect.set;
var moment = require("moment");
var forms_1 = require("@angular/forms");
var GrouplistComponent = /** @class */ (function () {
    function GrouplistComponent(groupService, _message, confirmServ, activatedRoute, router, fb) {
        var _this = this;
        this.groupService = groupService;
        this._message = _message;
        this.confirmServ = confirmServ;
        this.activatedRoute = activatedRoute;
        this.router = router;
        this.fb = fb;
        this.isCollapsed = false;
        this.typeOpen = true;
        this.sliderWidth = 180;
        this.total = 0;
        this.loading = true;
        this.pageSize = 10;
        this.page = 1;
        this.name = '';
        this.status = '';
        this.order = {
            "start_date": "desc",
            'created_at': "desc"
        };
        this.orderJson = {
            "start_date": 'descend'
        };
        this.stage = 1; // 1-	未开始  2-进行中  3-已结束 4-已暂停
        this.group_type = 0; // 1 - 普通 2 - 拉新 3 - 抽奖
        this.groupsList = [];
        this.checkedIds = [];
        this._allChecked = false;
        this._indeterminate = false;
        this.isVisibleMiddle = false;
        this.aliyunOssOutputUrl = api_1.AliyunOssOutputUrl;
        this.start_date = null;
        this.end_date = null;
        this._checked = false;
        this.qodeFormStatus = false;
        this.isLoadingAdd = false;
        this.qrcodeList = [];
        this.activityId = null;
        this.activity_goods_id = null;
        this.qrcodePageSize = 3;
        this.qrcodePage = 1;
        this.qrcodeTotal = 0;
        this.qrcodePageList = [];
        this.startIndex = 0;
        this.endIndex = 0;
        this.codeLoading = false;
        this.flag = true;
        this.newArray = function (len) {
            var result = [];
            for (var i = 0; i < len; i++) {
                result.push(i);
            }
            return result;
        };
        this._startValueChange = function () {
            if (_this.start_date > _this.end_date) {
                _this.end_date = null;
            }
        };
        this._endValueChange = function () {
            if (_this.start_date > _this.end_date) {
                _this.start_date = null;
            }
        };
        this._disabledStartDate = function (startValue) {
            var now = new Date();
            now.setHours(0, 0, 0, 0);
            var now_time = now.getTime();
            if (!startValue || !_this.qrcodeForm.value.validity_end) {
                return startValue < now_time;
            }
            return (startValue.getTime() >= _this.qrcodeForm.value.validity_end.getTime()) || (startValue.getTime() <= Date.now());
        };
        this._disabledEndDate = function (endValue) {
            var now = new Date();
            now.setHours(0, 0, 0, 0);
            var now_time = now.getTime();
            if (!endValue || !_this.start_date) {
                return endValue.getTime() < now_time;
            }
            return endValue.getTime() < _this.start_date.getTime();
        };
        var self = this;
        if (Object.keys(this.activatedRoute.queryParams['_value']).length) {
            this.activatedRoute.queryParams.subscribe(function (queryParams) {
                self.group_type = parseInt(queryParams.type) - 1;
                self.changeGroupStage(parseInt(queryParams.stage));
            });
        }
        else {
            this.group_type = 0;
            this.changeGroupStage(1);
        }
        this.qrcodeForm = this.fb.group({
            start_date: [null, [forms_1.Validators.required]],
            end_date: [null, [forms_1.Validators.required]],
            head_free_price: [0, [forms_1.Validators.required]],
            id: [null, [forms_1.Validators.required]],
            activity_goods_id: [null, [forms_1.Validators.required]],
            is_give: [false],
            is_show: [false]
        });
    }
    GrouplistComponent.prototype.addQodeForm = function () {
        if (this.qodeFormStatus) {
            return;
        }
        this.qodeFormStatus = true;
    };
    GrouplistComponent.prototype.cancelAddCode = function () {
        if (this.isLoadingAdd) {
            this._message.create('warning', '正在添加中,请勿取消');
            return;
        }
        this.qodeFormStatus = false;
    };
    GrouplistComponent.prototype.openType = function (item, type) {
        var _this = this;
        item[type] = !item[type];
        var activityId = item.id;
        var activityGoodsId = item.activity_goods[0].id;
        if (item[type] && type == 'showProduct') {
            var flag_1 = true;
            var index_1 = 0;
            this.groupsList.forEach(function (e, i) {
                if (e.id == item.id) {
                    index_1 = i;
                    if (e.goodsInfo) {
                        flag_1 = false;
                    }
                }
            });
            if (flag_1) {
                this.groupService.getGoodsDetail(activityId, activityGoodsId).subscribe(function (res) {
                    if (res.data.goods_num) {
                        res.data.goods_numList = res.data.goods_num.split('|');
                    }
                    if (res.data.prize_info) {
                        res.data.prize_info.forEach(function (item3) {
                            if (item3.prize_num) {
                                item3.prize_num = item3.prize_num.split("|");
                            }
                        });
                        _this.groupsList[index_1].goodsInfo = res.data;
                    }
                    else {
                        _this.groupsList[index_1].goodsInfo = res.data;
                        _this.groupsList[index_1].goodsInfo.prize_info = [];
                    }
                });
            }
        }
        ;
        if (item[type] && type == 'showGroup') {
            var flag_2 = true;
            var index_2 = 0;
            this.groupsList.forEach(function (e, i) {
                if (e.id === item.id) {
                    index_2 = i;
                    if (e.groupInfo) {
                        flag_2 = false;
                    }
                }
            });
            if (flag_2) {
                this.groupService.getGroupDetail(activityId, activityGoodsId).subscribe(function (res) {
                    _this.groupsList[index_2].groupInfo = res.data;
                });
            }
        }
    };
    GrouplistComponent.prototype._checkAll = function (value) {
        var _this = this;
        if (value) {
            this.groupsList.forEach(function (item) {
                if (!item.checked) {
                    item.checked = true;
                    _this.checkedIds.push(item.id);
                }
            });
        }
        else {
            this.groupsList.forEach(function (item) {
                if (item.checked) {
                    item.checked = false;
                    _this.checkedIds.every(function (val, idx, array) {
                        if (item.id === val) {
                            _this.checkedIds.splice(idx, 1);
                            return false;
                        }
                        return true;
                    });
                }
            });
        }
        this._refreshStatus();
    };
    ;
    GrouplistComponent.prototype.checkedSingele = function (e, id) {
        var _this = this;
        if (e) {
            this.checkedIds.push(id);
        }
        else {
            this.checkedIds.every(function (val, idx, array) {
                if (id === val) {
                    _this.checkedIds.splice(idx, 1);
                    return false;
                }
                return true;
            });
            this.groupsList.every(function (val, idx, array) {
                if (id === val.id) {
                    val.checked = false;
                    return false;
                }
                return true;
            });
        }
        this._refreshStatus();
    };
    GrouplistComponent.prototype._refreshStatus = function () {
        var allChecked = this.groupsList.every(function (value) { return value.checked === true; });
        var allUnChecked = this.groupsList.every(function (value) { return !value.checked; });
        console.log(allChecked, allUnChecked);
        this._allChecked = allChecked;
        this._indeterminate = (!allChecked) && (!allUnChecked);
    };
    ;
    GrouplistComponent.prototype.goAddPage = function (i) {
        if (this.flag) {
            this.router.navigate([i != 3 ? 'member/group/add/' + i : 'member/group/add-lottery/' + i], {
                queryParams: {
                    type: this.group_type + 1,
                    stage: this.stage
                }
            });
            this.flag = false;
        }
    };
    GrouplistComponent.prototype.goEditPage = function (id) {
        if (this.flag) {
            this.router.navigate([this.group_type === 2 ? 'member/group/edit-lottery/' + id : 'member/group/edit/' + id], {
                queryParams: {
                    'type': this.group_type + 1,
                    'stage': this.stage
                }
            });
            this.flag = false;
        }
    };
    GrouplistComponent.prototype.goWinnerPage = function (id) {
        if (this.flag) {
            this.router.navigate(['winners-detail/' + id], {
                queryParams: {
                    'type': this.group_type + 1,
                    'stage': this.stage
                }
            });
            this.flag = false;
        }
    };
    GrouplistComponent.prototype.goResetPage = function (id) {
        if (this.flag) {
            this.router.navigate([this.group_type === 2 ? 'member/group/add-lottery/' + id : "member/group/add/" + (this.group_type + 1) + "/" + id], {
                queryParams: {
                    'type': this.group_type + 1,
                    'stage': this.stage
                }
            });
        }
    };
    GrouplistComponent.prototype.saveStatus = function () {
        if (this.stage == 2) {
            window.localStorage.setItem('status', '1');
        }
        else if (this.stage == 4) {
            window.localStorage.setItem('status', '2');
        }
        else {
            window.localStorage.setItem('status', '');
        }
    };
    GrouplistComponent.prototype.toggleCollapsed = function (value) {
        this.isCollapsed = value;
        if (!this.isCollapsed) {
            this.typeOpen = true;
        }
    };
    GrouplistComponent.prototype.showShadow = function (i, flag) {
        console.log(flag);
        if (!flag) {
            this.qrcodePageList[i]['shadow'] = true;
        }
    };
    GrouplistComponent.prototype.hideShadow = function (i, flag) {
        if (!flag) {
            this.qrcodePageList[i]['shadow'] = false;
        }
    };
    GrouplistComponent.prototype.toggleShow = function (qrcode) {
        var _this = this;
        var status = qrcode.status === '正常' ? '暂停' : '正常';
        this.groupService.postActivityStatus(qrcode.id, status).subscribe(function (res) {
            if (res.code === 2000) {
                _this._message.create('success', "\u4FEE\u6539\u6210\u529F");
                _this.getQrCodeList();
            }
            else {
                _this._message.create('error', res.message);
            }
        });
    };
    GrouplistComponent.prototype.getFormControl = function (name) {
        return this.qrcodeForm.controls[name];
    };
    GrouplistComponent.prototype.ngOnInit = function () {
        this.groupsList = [{
                id: 1,
                name: '巧妈妈澳大利亚精品500克果冻转发朋友圈朋友圈友圈',
                state: 1,
                price: 10000,
                start: '2017.01.31',
                end: '2017.12.25',
                showGroup: true,
                showProduct: true
            }];
        this.loading = false;
        this.qrcodeForm.controls['start_date'].setValue(new Date(moment(new Date().getTime()).format('YYYY-MM-DD') + ' 00:00:00'));
        this.qrcodeForm.controls['end_date'].setValue(new Date(moment(new Date().getTime()).format('YYYY-MM-DD') + ' 23:59:59'));
    };
    GrouplistComponent.prototype.getList = function (clearPage, side) {
        var _this = this;
        if (clearPage) {
            this.page = 1;
            this.order = {
                "start_date": "desc",
                'created_at': "desc"
            };
            this.orderJson = {
                "start_date": 'descend'
            };
        }
        this.loading = true;
        this._allChecked = false;
        this.checkedIds = [];
        if (side) {
            this.router.navigate(['member/group/list'], {
                queryParams: {
                    type: this.group_type + 1,
                    stage: this.stage,
                }
            });
            this.order = {
                "start_date": "desc",
                'created_at': "desc"
            };
            this.orderJson = {
                "start_date": 'descend'
            };
            if (this.stage == 2) {
                this.status = '1';
            }
            else if (this.stage == 4) {
                this.status = '2';
            }
            else {
                this.status = '';
            }
        }
        this.groupService.getActivityList(this.page, this.pageSize, this.stage, this.group_type + 1, this.name, JSON.stringify(this.order), this.status).subscribe(function (res) {
            if (res.code === 2000) {
                _this.total = res.data.total;
                _this.groupsList = res.data.data;
                _this.groupsList.map(function (e, i) {
                    e.activity_goods[0].price = e.activity_goods[0].price / 1000;
                    var date = new Date(e['end_date'] + ' 23:59:59').getTime();
                    var date1 = new Date().getTime();
                    e['effective'] = true;
                    if (date < date1) {
                        e['effective'] = false;
                    }
                });
                _this._indeterminate = false;
            }
            else {
                _this.groupsList = [];
            }
            _this.loading = false;
        });
    };
    GrouplistComponent.prototype.sort = function (type, value) {
        if (value) {
            this.order[type] = value.substring(0, value.length - 3);
            this.order['created_at'] = value.substring(0, value.length - 3);
            this.orderJson[type] = value;
        }
        else {
            this.orderJson[type] = 'descend';
            this.order[type] = 'desc';
            this.order['created_at'] = 'desc';
        }
        this.page = 1;
        this.getList();
    };
    GrouplistComponent.prototype.changeGroupStage = function (stage) {
        this.stage = stage;
        this.name = '';
        this._allChecked = false;
        this.checkedIds = [];
        this.order = {
            "start_date": "desc",
            'created_at': "desc"
        };
        this.orderJson = {
            "start_date": 'descend'
        };
        this.getList(true, true);
    };
    GrouplistComponent.prototype.deleteGroup = function (id) {
        var self = this;
        this.confirmServ.confirm({
            title: "\u5220\u9664\u62FC\u56E2",
            content: '您确定要删除此拼团吗？',
            onOk: function () {
                self.groupService.delActivity(id).subscribe(function (res) {
                    if (res.code === 2000) {
                        var _lastCheckedIds_1 = self.checkedIds;
                        self._message.create('success', "\u62FC\u56E2\u5220\u9664\u6210\u529F");
                        self.page = 1;
                        self.getList();
                        setTimeout(function () {
                            self.checkedIds = [];
                            _lastCheckedIds_1.forEach(function (e, i) {
                                self.checkedSingele(true, e);
                                self.groupsList.forEach(function (e1, i1) {
                                    if (e1.id === e) {
                                        e1.checked = true;
                                    }
                                });
                            });
                            self.checkedSingele(false, id);
                            if (self.groupsList.length === 0) {
                                self._indeterminate = false;
                                self._allChecked = false;
                            }
                        }, 300);
                    }
                    else {
                        self._message.create('error', res.message);
                    }
                });
            },
            onCancel: function () {
            }
        });
    };
    // 修改拼团状态
    GrouplistComponent.prototype.changeGroupStatus = function (id, status) {
        var title, content;
        if (status === '正常') {
            title = '恢复拼团';
            content = '您确定要恢复此拼团吗？';
        }
        else {
            title = '暂停拼团';
            content = '您确定要暂停此拼团吗？';
        }
        var self = this;
        this.confirmServ.confirm({
            title: title,
            content: content,
            onOk: function () {
                self.groupService.postActivityStatus(id, status).subscribe(function (res) {
                    if (res.code === 2000) {
                        self._message.create('success', "\u62FC\u56E2\u72B6\u6001\u4FEE\u6539\u6210\u529F");
                        var _lastCheckedIds_2 = self.checkedIds;
                        self.page = 1;
                        self.getList();
                        setTimeout(function () {
                            self.checkedIds = [];
                            _lastCheckedIds_2.forEach(function (e, i) {
                                self.checkedSingele(true, e);
                                self.groupsList.forEach(function (e1, i1) {
                                    if (e1.id === e) {
                                        e1.checked = true;
                                    }
                                });
                            });
                            self.checkedSingele(false, id);
                        }, 300);
                    }
                    else {
                        self._message.create('error', res.message);
                    }
                });
            },
            onCancel: function () {
            }
        });
    };
    GrouplistComponent.prototype.deleteCheckedGroup = function () {
        var self = this;
        if (this.checkedIds.length > 0) {
            this.confirmServ.confirm({
                title: "\u6279\u91CF\u5220\u9664\u62FC\u56E2",
                content: '您确定要批量删除拼团吗？',
                onOk: function () {
                    var num = 0;
                    self.checkedIds.map(function (e, i) {
                        self.groupService.delActivity(e).subscribe(function (res) {
                            if (res.code === 2000) {
                                num++;
                                if (num === self.checkedIds.length) {
                                    self._message.create('success', "\u62FC\u56E2\u6279\u91CF\u5220\u9664\u6210\u529F");
                                    self.page = 1;
                                    self.getList();
                                }
                            }
                            else {
                                self._message.create('error', res.message);
                            }
                        });
                    });
                },
                onCancel: function () {
                }
            });
        }
    };
    GrouplistComponent.prototype.batchCheckedGroupStatus = function (status) {
        var self = this;
        if (this.checkedIds.length > 0) {
            this.confirmServ.confirm({
                title: "\u6279\u91CF" + status + "\u62FC\u56E2",
                content: "\u60A8\u786E\u5B9A\u8981\u6279\u91CF" + status + "\u62FC\u56E2\u5417\uFF1F",
                onOk: function () {
                    var num = 0;
                    self.checkedIds.map(function (e, i) {
                        self.groupService.postActivityStatus(e, status).subscribe(function (res) {
                            if (res.code === 2000) {
                                num++;
                                var _lastCheckedIds_3 = self.checkedIds;
                                if (num === self.checkedIds.length) {
                                    status = status === '正常' ? status = '恢复' : status;
                                    self._message.create('success', "\u62FC\u56E2\u72B6\u6001" + status + "\u6210\u529F");
                                    self.page = 1;
                                    self.getList();
                                    setTimeout(function () {
                                        self.checkedIds = [];
                                        _lastCheckedIds_3.forEach(function (e, i) {
                                            self.checkedSingele(true, e);
                                            self.groupsList.forEach(function (e1, i1) {
                                                if (e1.id === e) {
                                                    e1.checked = true;
                                                }
                                            });
                                            _lastCheckedIds_3.forEach(function (e, i) {
                                                self.checkedSingele(false, e);
                                            });
                                        });
                                    }, 500);
                                }
                            }
                            else {
                                self._message.create('error', res.message);
                            }
                        });
                    });
                },
                onCancel: function () {
                }
            });
        }
    };
    GrouplistComponent.prototype.showQrCodeModal = function (item) {
        this.activityId = item.id;
        this.activity_goods_id = item.activity_goods['0'].id;
        this.isVisibleMiddle = true;
        this.qrcodeForm.controls['id'].setValue(this.activityId);
        this.qrcodeForm.controls['activity_goods_id'].setValue(this.activity_goods_id);
        this.qrcodePage = 1;
        // this.groupService.getQrcodeList(this.activityId).subscribe(res => {
        //   res.data.data.forEach((e,i) => {
        //     console.log(e['activity_goods']['0']['qr_code_url']);
        //     if(e['activity_goods']['0']['qr_code_url']) {
        //       this.qrcodeTotal+=1;
        //     }
        //   })
        // });
        this.getQrCodeList();
    };
    GrouplistComponent.prototype.handleCancelMiddle = function (e) {
        this.isVisibleMiddle = false;
    };
    GrouplistComponent.prototype.handleOkMiddle = function (e) {
        this.isVisibleMiddle = false;
    };
    Object.defineProperty(GrouplistComponent.prototype, "_isSameDay", {
        get: function () {
            return this.start_date && this.end_date && moment(this.start_date).isSame(this.end_date, 'day');
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GrouplistComponent.prototype, "_endTime", {
        get: function () {
            var _this = this;
            return {
                nzHideDisabledOptions: true,
                nzDisabledHours: function () {
                    return _this._isSameDay ? _this.newArray(_this.start_date.getHours()) : [];
                },
                nzDisabledMinutes: function (h) {
                    if (_this._isSameDay && h === _this.start_date.getHours()) {
                        return _this.newArray(_this.start_date.getMinutes());
                    }
                    return [];
                },
                nzDisabledSeconds: function (h, m) {
                    if (_this._isSameDay && h === _this.start_date.getHours() && m === _this.start_date.getMinutes()) {
                        return _this.newArray(_this.start_date.getSeconds());
                    }
                    return [];
                }
            };
        },
        enumerable: true,
        configurable: true
    });
    GrouplistComponent.prototype.getQrCodeList = function (e) {
        var _this = this;
        this.codeLoading = true;
        if (e) {
            this.qrcodePage = e;
        }
        this.startIndex = (this.qrcodePage - 1) * this.qrcodePageSize - (this.qrcodePage != 1 ? 1 : 0);
        this.endIndex = this.qrcodePage * this.qrcodePageSize - (this.qrcodePage != 1 ? 1 : 0);
        // this.startIndex = (this.qrcodePage - 1) * this.qrcodePageSize;
        // this.endIndex = this.qrcodePage * this.qrcodePageSize - 1;
        //分页切换
        // if(this.qrcodePage == 1) {
        //   this.qrcodePageSize = 2;
        // } else {
        //   this.qrcodePageSize = 3;
        // }
        // this.startIndex = (this.qrcodePage - 1) * this.qrcodePageSize + (this.qrcodePage === 1 ? 0 : -1);
        // this.endIndex = this.qrcodePage === 1 ? this.startIndex + 1 : this.startIndex + 2;
        this.groupService.getQrcodeList(this.activityId).subscribe(function (res) {
            _this.codeLoading = false;
            _this.qrcodeList = res.data.data;
            if (res.data.total != 0 && res.data.total % 3 == 0) {
                _this.qrcodeTotal = res.data.total + 1;
            }
            else {
                _this.qrcodeTotal = res.data.total;
            }
            _this.qrcodePageList = [];
            _this.qrcodeList.forEach(function (e, i) {
                var nowTime = new Date().getTime();
                if (i >= _this.startIndex && i <= _this.endIndex) {
                    if (nowTime > new Date(e['end_date']).getTime() + 86400000) {
                        e['invalid'] = true;
                    }
                    else {
                        e['invalid'] = false;
                    }
                    _this.qrcodePageList.push(e);
                }
            });
            // if(this.qrcodePageList.length) {
            //   let nowTime = new Date().getTime();
            //   this.qrcodePageList.map((e,i) => {
            //     if(nowTime > new Date(e['end_date']).getTime() + 86400000) {
            //       e['invalid'] = true;
            //     } else {
            //       e['invalid'] = false;
            //     }
            //   });
            // }
        });
        // this.qrcodeTotal =  this.qrcodeTotal + (this.qrcodeTotal === this.endIndex + 1 ? 1 : 0);
        // console.log(this.qrcodeTotal);
        // this.endIndex = this.endIndex + (this.qrcodeTotal == this.endIndex - 1 ? 1: 0);
        // this.qrcodePageList = this.qrcodeList.slice(this.startIndex,this.endIndex);
        // console.log(this.qrcodePageList);
        // })
        //每页有新增
        // this.startIndex = (this.qrcodePage - 1) * this.qrcodePageSize;
        // this.endIndex = this.qrcodePage * this.qrcodePageSize;
        // this.groupService.getQrcodeList(this.activityId,this.qrcodePage,this.qrcodePageSize).subscribe(res => {
        //   this.qrcodeList = res.data.data;
        //   this.qrcodeTotal = res.data.total;
        //   this.codeLoading = false;
        //   if(this.qrcodeList.length) {
        //     let nowTime = new Date().getTime();
        //     this.qrcodeList.map((e,i) => {
        //       if(nowTime > new Date(e['end_date']).getTime() + 86400000) {
        //         e['invalid'] = true;
        //       } else {
        //         e['invalid'] = false;
        //       }
        //     });
        //   }
        // });
    };
    GrouplistComponent.prototype.downloadQrcode = function (src, name) {
        // let url = src;
        // let a = document.createElement('a');
        // let event = new MouseEvent('click');
        // a.href = url;
        // a.download = name || '二维码图片';
        // a.dispatchEvent(event);
        // var oPop = window.open(src,"","width=1, height=1, top=5000, left=5000");
        //     // for(; oPop.document.readyState != "complete"; )
        //     // { if (oPop.document.readyState == "complete")break; }
        //     // oPop.document.execCommand("SaveAs"); oPop.close();
        window.open(src);
    };
    GrouplistComponent.prototype._submitForm = function () {
        var _this = this;
        this.isLoadingAdd = true;
        this.qrcodeForm.value['is_give'] = this.qrcodeForm.value['is_give'] ? 1 : 0;
        this.qrcodeForm.value['is_show'] = this.qrcodeForm.value['is_show'] ? 1 : 0;
        this.qrcodeForm.value['start_date'] = moment(this.qrcodeForm.value.start_date).format('YYYY-MM-DD');
        this.qrcodeForm.value['end_date'] = moment(this.qrcodeForm.value.end_date).format('YYYY-MM-DD');
        var data = this.qrcodeForm.value;
        this.groupService.addQrcode(data).subscribe(function (res) {
            if (res.code === 2000) {
                _this.qrcodePage = 1;
                _this.getQrCodeList();
                _this.qodeFormStatus = false;
                _this.qrcodeForm.controls['start_date'].setValue(new Date(moment(new Date().getTime()).format('YYYY-MM-DD') + ' 00:00:00'));
                _this.qrcodeForm.controls['end_date'].setValue(new Date(moment(new Date().getTime()).format('YYYY-MM-DD') + ' 23:59:59'));
                _this.qrcodeForm.controls['is_give'].setValue(false);
                _this.qrcodeForm.controls['is_show'].setValue(false);
                _this._message.create('success', res.message);
            }
            else {
                _this._message.create('error', res.message);
            }
            _this.isLoadingAdd = false;
        });
        // setTimeout(() => {
        //   if(!this.qrcodeList[this.activityId]) {
        //     this.qrcodeList[this.activityId] = [];
        //   }
        //   this.qrcodeList[this.activityId].push(this.qrcodeForm.value);
        //   this.qrcodePage = 1;
        //   this.qrcodePageList[this.activityId] = this.qrcodeList[this.activityId].slice(0,2);
        //   this.isLoadingAdd = false;
        //   this.qodeFormStatus = false;
        // },2000);
    };
    GrouplistComponent = __decorate([
        core_1.Component({
            selector: 'app-group-list',
            templateUrl: './grouplist.component.html',
            styleUrls: ['./grouplist.component.scss'],
        })
    ], GrouplistComponent);
    return GrouplistComponent;
}());
exports.GrouplistComponent = GrouplistComponent;
